/*
 * LowerRightLocation.java
 *
 * Created on 19 maart 2008, 10:48
 *
 * @author wijnand.schepens@hogent.be
 */

package model.graphic.locations;

import java.io.Serializable;

/**
 * Decorator Location constraining a location to lie right and below a reference location.
 * Note: x and y are restricted separately
 */
public class LowerRightLocation implements Location, Serializable
{
	protected Location location;
	protected Location locationRef;
	
	public LowerRightLocation(Location location, Location locationRef)
	{
		this.location = location;
		this.locationRef = locationRef;
	}

	public int getX()
	{
		return location.getX();
	}

	public int getY()
	{
		return location.getY();
	}

	public void setXY(int x, int y)
	{
		int minX = locationRef.getX();
		int minY = locationRef.getY();
		location.setXY(x < minX ? minX : x, y < minY ? minY : y);
	}

    public void print(){
        System.out.println("lowright x: "+location.getX()+" - y: "+location.getY());
    }
	
}
